const UserService = require("../services/UserService")

const UserController = {
    addUser: async (req, res) => {
        //插入数据库
        /*
        1. 创建一个模型
        */
        const {
            username,
            password,
            age
        } = req.body
        await UserService.addUser(username, password, age);
        res.send({
            ok: 1
        })

    },
    updateUser: async (req, res) => {
        await UserService.updateUser(req.params.id, req.body);
        res.send({
            ok: 1
        })

    },
    deleteUser: async (req, res) => {
        await UserService.deleteUser(req.params.id)
        res.send({
            "ok": 1
        })


    },
    getUser:async(req,res)=>{
        const {page,limit}=req.query
        //-1：倒序，1:正序
      let data= await UserService.getUser(page,limit)
          res.send(data)
  
      
      }


}

module.exports = UserController